package cn.gson.fengboot.controller;

import cn.gson.fengboot.model.DmypojisVo.Myrolesone;
import cn.gson.fengboot.model.pojos.*;
import cn.gson.fengboot.model.service.DdepService;
import cn.gson.fengboot.model.service.DrolesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@RestController
@RequestMapping("/roles")
public class DrolesController {

    @Autowired
    DrolesService service;


    /*查询该职位的部门权限*/
    @RequestMapping("/selectmyroles")
    public Map<String,Object> myroles(Integer roleId){
        Map<String,Object> map = new HashMap<>();
        map.put("mydeproles",service.myroles(roleId));//该职位已有的部门权限
        map.put("myallroles",service.selectmyallroles(roleId));//该职位已有的权限
        map.put("listroles",service.selectlistroles());//查询所有列表权限数据
        return map;
    }

    /*新增该职位的权限*/
    @RequestMapping("/saverolesarr")
    public void saverolesarr(String rolesarr){
        service.saverolesarr(rolesarr);
    }


    /*新增岗位角色*/
    @RequestMapping("/savemynewroles")
    public void savemynewroles(@RequestBody QroleFrom qroleFrom){
        service.savemynewroles(qroleFrom);
    }

    /*查询角色是否可以删除*/
    @RequestMapping("/myisnomyroles")
    public Integer myisnomyroles(Integer roleId){
        return service.myisnomyroles(roleId);
    }

    /*查询该部门对应的岗位*/
    @RequestMapping("/rolearrByDepId")
    public List<QroleFrom> rolearrByDepId(Integer depId){
        return service.findAllByDepId(depId);
    }
}
